<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateStoreBargainsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('store_bargains', function (Blueprint $table) {
            $table->id()->comment('砍价表');
            $table->integer('product_id')->comment('商品ID')->index();
            $table->integer('bargain_user_id')->nullable()->comment('用户砍价的ID')->index();
            $table->integer('shop_id')->comment('店铺ID')->index();
            $table->string('title')->comment('砍价活动的名称');
            $table->string('pic')->comment('砍价活动图片');
            $table->string('store_name')->nullable()->comment('砍价商品名称');
            $table->json('rotation_chart')->comment('砍价商品轮播图');
            $table->string('unit_name',16)->comment('单位名称');
            $table->decimal('price',8,2)->comment('砍价金额');
            $table->decimal('min_price',8,2)->comment('砍价商品最低价');
            $table->decimal('bargain_max_price',8,2)->default(0.00)->comment('用户每次砍价的最大金额');
            $table->decimal('bargain_min_price',8,2)->default(0.00)->comment('用户每次砍价的最小金额');
            $table->timestamp('start_at')->comment('砍价开启时间');
            $table->timestamp('stop_at')->comment('砍价结束时间');
            $table->string('desc')->nullable()->comment('活动分享的描述');
            $table->string('introduction')->comment('砍价活动简介');
            $table->integer('temp_id')->nullable()->comment('模板ID')->index();
            $table->text('rule')->nullable()->comment('砍价规则');
            $table->integer('stock')->default(0)->comment('库存');
            $table->integer('sales')->default(0)->comment('销量');
            $table->decimal('give_integral',8,2)->default(0.00)->comment('返多少积分');
            $table->integer('num')->default(0)->comment('可购买砍价商品数量');
            $table->integer('sort')->default(0)->comment('排序');
            $table->integer('look')->default(0)->comment('砍价商品浏览量');
            $table->integer('share')->default(0)->comment('砍价商品分享量');
            $table->integer('quota')->default(0)->comment('限购总数');
            $table->integer('quota_show')->default(0)->comment('限量总数显示');
            $table->integer('people_num')->default(1)->comment('用户帮砍的次数');
            $table->decimal('weight',8,2)->default(0.00)->comment('重量');
            $table->decimal('volume',8,2)->default(0.00)->comment('体积');
            $table->decimal('postage',10,2)->nullable()->comment('邮费');
            $table->decimal('cost_price',8,2)->nullable()->comment('成本价');
            $table->integer('participants')->default(0)->comment('参与的人数');
            $table->integer('buyers')->default(0)->comment('购买的人数');
            $table->tinyInteger('is_recommend')->default(0)->comment('是否推荐 0不推荐 1推荐');
            $table->tinyInteger('is_postage')->default(1)->comment('是否包邮 0不包邮 1包邮');
            $table->tinyInteger('status')->default(0)->comment('砍价状态 0(到砍价时间不自动开启)  1(到砍价时间自动开启时间)');
            $table->string('active_status')->default('noCompleted')->comment('状态 haveInHand：进行中 completed:已结束 noCompleted:未开始');
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('store_bargains');
    }
}
